package com.baizhi.lql.controller;

import com.baizhi.lql.dto.Dto;
import com.baizhi.lql.entity.User;
import com.baizhi.lql.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("queryPage")
    @ResponseBody
    public Map<String,Object> queryPage(@RequestBody Dto dto){

        return userService.queryAllPage(dto.getPage(), dto.getPageSize());
    }
    @RequestMapping("queryOne")
    @ResponseBody
    public User queryOne(int id){
        return userService.queryOne(id);
    }
    @RequestMapping("modify")
    @ResponseBody
    public Map<String,Object> modify(@RequestBody User user){
        return userService.modify(user.getId(), user.getStatus(), user);
    }
}
